function confirmurl(url,message) {
	url = url;
	if(confirm(message)) redirect(url);
}
function redirect(url) {
	location.href = url;
}	
String.prototype.Trim=function(){
			return this.replace(/(^\s*)|(\s*$)/g, "");
		}
	function checkusername(){
		var textval = $('#username').val().Trim();
		//var unLen = textval.replace(/[^\x00-\xff]/g, "**").length;
		var temp = /^[A-Za-z0-9]+$/;
		var flag = temp.test(textval);
		var cu = $('#usernamemsg');
		if(textval=='') {
		warning(cu, '用户名不能为空');
		setstatus('usernamestau','failed');
		}else if(!flag){
		warning(cu, '请输入字母或数字');
			setstatus('usernamestau','failed');
		}else if(textval.length > 16 || textval.length <5 ){
			warning(cu, '确认密码为5-16位');
			setstatus('usernamestau','failed');
		}else{
			ok(cu, '输入正确');
			setstatus('usernamestau','pass');
		}
	} 
	function checktruename(){
		var textval = $('#truename').val().Trim();
		//var unLen = textval.replace(/[^\x00-\xff]/g, "**").length;
		var temp = /^[\u0391-\uFFE5]+$/;
		var flag = temp.test(textval);
		var cu = $('#truenamemsg');
		if(textval=='') {
		warning(cu, '姓名不能为空');
		setstatus('truenamestau','failed');
		}else if(!flag){
		warning(cu, '请输入中文姓名');
			setstatus('truenamestau','failed');
		}else{
			ok(cu, '输入正确');
			setstatus('truenamestau','pass');
		}
	}
	function checkpassword(){
		var textval = $('#password').val().Trim();
		var cu = $('#passwordmsg');
		if(textval==''){
			warning(cu, '密码不能为空');
			setstatus('passwordstau','failed');
		}else if(textval.length > 18 || textval.length <6 ){
			warning(cu, '密码为6-18位');
			setstatus('passwordstau','failed');
		}else{
			ok(cu, '输入正确');
			setstatus('passwordstau','pass');
		}
	}
	function checkrepass(){
		var textval = $('#repass').val().Trim();
		var textvalue = $('#password').val().Trim();
		var cu = $('#repassmsg');
		if(textval == ''){
			warning(cu, '确认密码不能为空');
			setstatus('repassstau','failed');
		}else if(textval != textvalue){
			warning(cu, '密码不一致');
			setstatus('repassstau','failed');
		}else if(textval.length > 18 || textval.length <6 ){
			warning(cu, '确认密码为6-18位');
			setstatus('repassstau','failed');
		}else{
			ok(cu, '输入正确');
			setstatus('repassstau','pass');
		}
		
	}
	function checkmobile(){
		var telephoneval = $('#mobile').val().Trim(); 
		var tmp = /^1[3-9]\d{9}$/;     //支持11位手机号码验证
		//var tel = /^\d{3,4}-?\d{7,9}$/; 
		var flag=tmp.test(telephoneval);
		var cu = $('#mobilemsg');
		if(telephoneval==''){
			warning(cu, '手机号码不能为空');
			setstatus('telephonestau','failed');
		}else if(!flag) {
			warning(cu, '请输入正确手机手机号码');
			setstatus('mobilestau','failed');
		}else{
				ok(cu, '输入正确');
				setstatus('mobilestau','pass');
			}
	} 
	function checkemail(){
		var emailval = $('#email').val().Trim();
		var tmp1 =  /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
		var flag2 = tmp1.test(emailval);
		var cu = $('#emailmsg');
		if(emailval=='') {
		warning(cu, '邮箱不能为空');
		setstatus('emailstau','failed');
		}else if(!flag2){
			warning(cu, '请输入正确邮箱');
			setstatus('emailstau','failed');
		}else{
			ok(cu, '输入正确');
			setstatus('emailstau','pass');
		}
}
function warning(obj, msg) {
	obj.html('<font color="red">'+msg+'</font>');	
}
function ok(obj, msg) {
	obj.html('<font color="green">'+msg+'</font>');	
}
function setstatus(namestau,failed){
	$('#'+namestau+'').val(failed);
}
function checkaddsubmit(){
	var usernamestau = $('#usernamestau').val();
    var truenamestau = $('#truenamestau').val();
	var passwordstau = $('#passwordstau').val();
	var repassstau = $('#repassstau').val();
    var mobilestau = $('#mobilestau').val();
    var emailstau = $('#emailstau').val();
    if(truenamestau=='pass'&& mobilestau=='pass' && emailstau=='pass'&& usernamestau=='pass' && passwordstau=='pass' && repassstau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }
}
function checkpwdsubmit(){
	var passwordstau = $('#passwordstau').val();
	var repassstau = $('#repassstau').val();
	if(passwordstau=='pass' && repassstau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }
}
function checksetsubmit(){
    var truenamestau = $('#truenamestau').val();
    var mobilestau = $('#mobilestau').val();
    var emailstau = $('#emailstau').val();
    if(truenamestau=='pass'&& mobilestau=='pass' && emailstau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }

}

function checkadtitle(){
	var adtitle = $('#adtitle').val();
	var cu = $('#adtitlemsg');
	if(adtitle==''){
		warning(cu, '广告标题不能为空,请输入标题');
		setstatus('adtitlestau','failed');
			}
	else{
		ok(cu, '输入正确');
		setstatus('adtitlestau','pass');
	}
}
function checkadprice(){
	var adprice = $('#adprice').val();
	var cu = $('#adpricemsg');
	if(adprice==''){
		warning(cu, '广告价格不能为空,请输入价格');
		setstatus('adpricestau','failed');
			}else if(isNaN(adprice)){
				warning(cu, '价格请输入数字');
				setstatus('adpricestau','failed');
			}
			else if(adprice=='0'){
				warning(cu, '价格不能为0');
				setstatus('adpricestau','failed');
			}
	else{
		ok(cu, '输入正确');
		setstatus('adpricestau','pass');
	}
}
function checkadputtime(){
	for(n=1;n<=7;n++){
		$("input[name='radio_name'][checked]").val();  //选择被选中Radio的Value值
		var putweek = $('#putweek'+n+'').attr("checked");//周几
	    var puttimestau = $(":radio[name=puttime"+n+"][checked]").val();//投放状态 
	    if(putweek && puttimestau!=0 && puttimestau!=1){
		   alert("请您选择投放的时间段");
		   setstatus('timestau','failed');
		   return false;
		   
	   }else{
		   setstatus('timestau','pass');  
	   }
	   if(puttimestau==1){
		var starttime = $('#starttime'+n+'').attr("value");
		alert (starttime);
		var endtime = $('#endtime'+n+'').attr("value");
		alert (endtime);
		var twostarttime = $('#twostarttime'+n+'').attr("value");
		alert(twostarttime);
		var twoendtime = $('#twoendtime'+n+'').attr("value");
		alert (twoendtime);
		if((starttime > endtime) || (twostarttime > twoendtime)){
			alert("请您选择正确的投放时间段");
			setstatus('puttimestau','failed');
			   return false;
		}else{
			setstatus('puttimestau','pass');
		}
	   }
		if(timestau=='pass'&& puttimestau=='pass'){
    	return true;
	    }else{
	    	alert('请正确填写信息');
	    	return false;
    }
 }
}

//验证关键词的添加
function checkword(){
		var wordval = $('#word').val().Trim(); 
		var cu = $('#wordmsg');
		if(wordval==''){
			warning(cu, '关键词不能为空');
			setstatus('wordstau','failed');
		}else{
				ok(cu, '输入正确');
				setstatus('wordstau','pass');
			}
	}

function checkurl(){
	var newurl = $('#url').val().Trim();
	var cu = $('#urlmsg');
	var Expression=/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
	var objExp=new RegExp(Expression);
	if(newurl == ''){
		warning(cu,'url不能为空');
		setstatus('urlstau','failed');
	}else if(objExp.test(newurl)==false){
		warning(cu,'url地址不正确');
		setstatus('urlstau','failed');
}
	else{
		ok(cu,'输入正确');
		setstatus('urlstau','pass');
	}
}
function checkprice(){
	var priceval = $('#price').val().Trim();
	var tmp = /^[([0-9]{1,3}|([0-9]{1,}[.][0-9]{1,2})|(0.[0-9]{1,2})]$/;
	var flag = tmp.test(priceval);
	var cu = $('#pricemsg');
	if(priceval == ''){
		warning(cu,'价格不能为空');
		setstatus('pricestau','failed');
	}else if(!flag){
		warning(cu,'价格只能为数字');
		setstatus('pricestau','failed');
	}else{
		ok(cu, '输入正确');
		setstatus('pricestau','pass');
	}
}

function checkdayconslimit(){
	var priceval = $('#dayconslimit').val().Trim();
	var tmp = /^[([0-9]{1,3}|([0-9]{1,}[.][0-9]{1,2})|(0.[0-9]{1,2})]$/;
	var flag = tmp.test(priceval);
	var cu = $('#dayconslimitmsg');
	 if(priceval!=''&&!flag){
		warning(cu,'价格只能为数字');
		setstatus('conslimitstau','failed');
	}else{
		ok(cu, '');
		setstatus('conslimitstau','pass');
	}
}
//推广管理检验
function checkpopusubmit(){
    var urlstau = $('#urlstau').val();
    //var pricestau = $('#pricestau').val();
    if(urlstau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }
}

function checkpopukeyword(){
	
	var wordval = $('#word').val().Trim(); 
	var cu = $('#wordmsg');
	if(wordval==''){
		warning(cu, '关键词不能为空');
		setstatus('wordstau','failed');
	}else{
			ok(cu, '输入正确');
			setstatus('wordstau','pass');
		}
	
	
}


//验证搜索配置的添加
function checkSearchName(){
	var wordval = $('#name').val().Trim(); 
	var cu = $('#namemsg');
	if(wordval==''){
		warning(cu, '关键词不能为空');
		setstatus('nametau','failed');
	}else{
		ok(cu, '输入正确');
		setstatus('nametau','pass');
	}
}
//推广管理检验
function checkSearchSubmit(){
	var nametau = $('#nametau').val();
    if(nametau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }
}


function checkrolename(){
	//alert('okkk');
	var roleval = $('#rolename').val().Trim(); 
	var cu = $('#rolenamemsg');
	if(roleval==''){
		warning(cu, '角色名不能为空');
		setstatus('rolenamestau','failed');
	}else{
			ok(cu, '输入正确');
			setstatus('rolenamestau','pass');
		}
}



function checkrolesubmit(){
	
    var rolenamestau = $('#rolenamestau').val();
    if(rolenamestau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }
}

//验证敏感词的添加
function checkbadword(){
		var wordval = $('#badword').val().Trim(); 
		var cu = $('#badwordmsg');
		if(wordval==''){
			warning(cu, '敏感词不能为空');
			setstatus('badwordstau','failed');
		}else{
				ok(cu, '输入正确');
				setstatus('badwordstau','pass');
			}
	}
function checkbwordsubmit(){
    var badwordstau = $('#badwordstau').val();
    if(badwordstau=='pass'){
    	return true;
    }else{
    	alert('请正确填写信息');
    	return false;
    }
}
function checktopupmoney(){
    var money = $('#money').val().Trim();
    var tmp = /^[([0-9]{1,}|([0-9]{1,}[.][0-9]{1,2})|(0.[0-9]{1,2})]$/;
    var flag = tmp.test(money);
    var cu = $('#moneymsg');
    if(money == ''){
        warning(cu,'*充值金额不能为空');
        setstatus('moneystau','failed');
    }else if(isNaN(money)){
        warning(cu,'*充值金额只能为数字');
        setstatus('moneystau','failed');
    }else{
        ok(cu, '输入正确');
        setstatus('moneystau','pass');
    }
}

function checktopupmoneysubmit(){
    var moneystau = $('#moneystau').val();
    if(moneystau=='pass'){
        return true;
    }else{
        alert('请正确填写信息');
        return false;
    }
}

//验证品牌的添加
function checkbrand(){
    var wordval = $('#keyword').val().Trim();
    var cu = $('#keywordmsg');
    if(wordval==''){
        warning(cu, '关键字不能为空');
        setstatus('keywordstau','failed');
    }else{
        ok(cu, '输入正确');
        setstatus('keywordstau','pass');
    }
}

    /*function checkstarttime(){
        var starttime = $('#tg_starttime').val();
        alert (starttime);
        var cu = $('#starttimemsg');
        if(starttime==''){
            warning(cu, '开始时间不能为空');
            setstatus('starttimestau','failed');
        }else{
            ok(cu, '输入正确');
            setstatus('starttimestau','pass');
        }
    }

    function checkendtime(){
        var endtime = $('#tg_endtime').val();

        var cu = $('#endtimemsg');
        if(endtime==''){
            warning(cu, '结束时间不能为空');
            setstatus('endtimestau','failed');
        }else{
            ok(cu, '输入正确');
            setstatus('endtimestau','pass');
        }
    }*/

function checkaddbrand(){
    var keywordstau = $('#keywordstau').val();
    var urlstau =$('#urlstau').val();
    var starttimestau = $('#starttimestau').val();
    var endtimestau = $('#endtimestau').val();
    if(keywordstau=='pass'&& urlstau=='pass'){
        return true;
    }else{
        alert('请正确填写信息');
        return false;
    }

}


function checkbrandusername(){
    var username = $('#username').val().Trim();
     var cu = $('#usernamemsg');
    if(username == ''){
        warning(cu,'用户名不能为空');
        setstatus('usernamestau','failed');
    }else{
        var query = {"username":username};
        $.ajax({
            type:"POST",
            url:"/admin.php/Public/checkusername",
            data:query,
            success:function(response){
                var sss = response.split("|") ;
                 if(sss[0]==1){
                    document.getElementById("usernamemsg").innerHTML='<font color="green">您输入的用户名正确</font>';
                }else{
                    document.getElementById("usernamemsg").innerHTML='<font color="green">您输入的用户名不正确，请重新输入</font>';
                }
            },
            error:function(XMLResponse){
            }
        });
        setstatus('usernamestau','pass');
    }


}

//检查新的类英文名称是否已经纯在
       function checkegname(){
                var textval = $('#newName').val().Trim();
                //var unLen = textval.replace(/[^\x00-\xff]/g, "**").length;
                var temp = /^[A-Za-z]+$/;
                var flag = temp.test(textval);
                var cu = $('#newNamemsg');
                if(textval=='') {
                warning(cu, '英文名称不能为空');
                setstatus('newNamestau','failed');
                }else if(!flag){
                warning(cu, '请输入字母');
                    setstatus('newNamestau','failed');
                }else{
                    var query = {"egnames":textval};
                    $.ajax({
                        type:"POST",
                        url:"/admin.php/Public/checkegname",
                        data:query,
                        success:function(response){
                            var sss = response.split("|") ;
                            if(sss[0]==1){
                                document.getElementById("newNamemsg").innerHTML='<font color="red">'+sss[1]+'</font>';
                                setstatus('newNamestau','failed');
                            }else{
                                document.getElementById("newNamemsg").innerHTML='<font color="green">'+sss[1]+'</font>';
                                setstatus('newNamestau','pass');
                            }
                        },
                        error:function(XMLResponse){
                        }
                    });
                }
        }
